package controllers

import (
	"github.com/astaxie/beego"
	"fmt"
"wcy-xmt-api/models"
)

// 视频直播
type VideoLiveController struct {
	beego.Controller
}

// @Title start
// @Description 开始直播
// @Param app form int true "App编号"
// @Param uid form int true "用户id"
// @Param chanId form int true "频道id"
// @Param token form string true "登陆成功token"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.StartLiveStatus
// @router /start [post]
func (this *VideoLiveController) Start() {
	fmt.Println("run VideoLiveController Start")
	resStatus := &models.ResStatus{}
	startStatus := &models.StartLiveStatus{}
	startStatus.Code = 0
	startStatus.SessionId = 232423423;
	startStatus.PushUrl = "rtmp://推送地址"
	startStatus.Message = "成功"

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title 频道列表
// @Description 获取频道列表
// @Param app form int true "当前App编号"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.Channels
// @router /changes [post]
func (this *VideoLiveController) Changes() {
	fmt.Println("run ImgTxtLiveController Changes")

	resStatus := &models.ResStatus{}
	channels := &models.Channels{}
	chanes := []*models.Channel{}

	channel := &models.Channel{1, "2016马拉松直播"}
	chanes = append(chanes, channel)
	channel = &models.Channel{2, "NBA总决赛"}
	chanes = append(chanes, channel)
	channel = &models.Channel{3, "直播大丰收"}
	chanes = append(chanes, channel)
	channel = &models.Channel{4, "百度夏季Party"}
	chanes = append(chanes, channel)
	channel = &models.Channel{5, "五马街闹元宵"}
	chanes = append(chanes, channel)

	channels.Code = 0
	channels.Data = chanes
	channels.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = channels
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title close
// @Description 关闭直播
// @Param app form int true "当前App编号"
// @Param uid form int true "用户id"
// @Param chanId form int true "图文频道id"
// @Param token form string true "登陆成功token"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.CloseStatus
// @router /close [post]
func (this *VideoLiveController) Close() {
	fmt.Println("run VideoLiveController Stop")
	resStatus := &models.ResStatus{}
	startStatus := &models.CloseStatus{}
	startStatus.Code = 0
	startStatus.ErrMsg = ""

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title 获取视频详情
// @Description 根据Id获取视频详情
// @Param app form int true "App编号"
// @Param id form int true "频道id"
// @Param type form int true "0回放，1直播"
// @Param uid form int false "用户id"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.VideoDesInfo
// @router /info [post]
func (this *VideoLiveController) GetVideoInfo() {
	fmt.Println("run VideoLiveController GetVideoInfo")
	resStatus := &models.ResStatus{}
	videoInfo := &models.VideoDesInfo{}
	videoInfo.Code = 0
	videoInfo.ErrMsg = ""
	video := &models.VideoDes{}
	video.ActiveNum = 23232
	video.Id = 1
	video.IsPraise = 1
	video.Time = "1小时前"
	video.Title = "直播吃烤鱼"
	views := []*models.View{}
	view := &models.View{1,232,"http://wangchuagn.bj.bcebos.com/lve-fmhbemt2h4eg4c0d/recording_20151209145613.mp4"}
	views = append(views,view)
	view = &models.View{2,233,"http://wangchuagn.bj.bcebos.com/lve-fmhbemt2h4eg4c0d/recording_20151209145613.mp4"}
	views = append(views,view)
	view = &models.View{3,323,"http://wangchuagn.bj.bcebos.com/lve-fmhbemt2h4eg4c0d/recording_20151209145613.mp4"}
	views = append(views,view)
	video.Views = views
	videoInfo.VideoDes = video
	resStatus.Code = 200
	resStatus.Data = videoInfo
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title Praise
// @Description 点赞
// @Param app form int true "App编号"
// @Param id form int true "频道id"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param type form int true "0回放，1直播"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.PraiseInfo
// @router /praise [post]
func (this *VideoLiveController) Praise() {
	fmt.Println("run VideoLiveController Praise")
	resStatus := &models.ResStatus{}
	startStatus := &models.PraiseInfo{}
	startStatus.Code = 0
	startStatus.ErrMsg = "";

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}

// @Title UnPraise
// @Description 取消点赞
// @Param app form int true "App编号"
// @Param id form int true "频道id"
// @Param uid form int true "用户id"
// @Param token form string true "登陆成功token"
// @Param type form int true "0回放，1直播"
// @Success 200 {object} models.ResStatus
// @Success 200 {object} models.PraiseInfo
// @router /unpraise [post]
func (this *VideoLiveController) UnPraise() {
	fmt.Println("run VideoLiveController UnPraise")
	resStatus := &models.ResStatus{}
	startStatus := &models.PraiseInfo{}
	startStatus.Code = 0
	startStatus.ErrMsg = "";

	resStatus.Code = 200
	resStatus.Data = startStatus
	resStatus.ErrMsg = "OK"

	this.Data["json"] = resStatus
	this.ServeJson()
}